<%@ page import="common.*,java.sql.*,db.*,java.util.*;" contentType="text/html; charset=utf-8" %>
<%
UserSession userSession = (UserSession)session.getAttribute("user"); 

String submenu_id 	= CommonUtil.nvl(request.getParameter("submenu_id"),"");
String submenu_idx 		= CommonUtil.nvl(request.getParameter("submenu_idx"),"");

String login_id = null;
String user_id = null;
String login_name = null;
String admin_level = null;

if(userSession!=null){
login_id = userSession.getLogin_id();
user_id = userSession.getUser_id();
login_name = userSession.getUser_name();
admin_level = userSession.getAdmin_level();
}

String[] param = new String[2];
param[0]=admin_level;
param[1]="Y";

ArrayList list_l =null;
HashMap map_1 = null;


String[] param_2 = new String[3];
param_2[0]=admin_level;
param_2[1]="N";
param_2[2]=submenu_id;

ArrayList list_2 =null;
HashMap map_2 = null;

Connection con=null;
DAO userdao = new DAO();
try {
	con = (new CommonConnect()).getConnection_ds1();
	String queryStr =  QueryManager.getQuery("menu_select.query");
	list_l = userdao.select(con,queryStr,param);
	
	queryStr =  QueryManager.getQuery("menu_sub_select.query");
	list_2 = userdao.select(con,queryStr,param_2);

} catch (Exception e) {
	e.printStackTrace();
}finally {
	  try{
		  if (con!=null) con.close();
	  }catch(Exception ee){}
}
%>
<script>

function go_sml_sub(){
	alert('대분류에서 등록하세요.');
}

function go_command_menu(v){
	var frm = document.submenuform;	
	frm.cmd.value=v;
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();	
}
</script>
<form name="submenuform"  method="post" action = "/speaking.pb" >
<input type="hidden" name="cmd" value="">
</form>

	<div id="subTitle">
        <ul>
<%
for (int i=0;list_l.size()>i ;i++){	
	map_1=(HashMap)list_l.get(i);
%>          
            <li><a href="#" onclick="go_command_menu('<%=(String)map_1.get("command") %>')" class="<%=(submenu_id.equals((String)map_1.get("command")))?"subTitleOn":""%>"><%=(String)map_1.get("menu_name") %></a></li>
<%
}
%>                        
       </ul>
    </div>
          
	<div id="subMenu">
	
		<ul>
		
<%
	for (int i=0;list_2.size()>i ;i++){	
		map_2=(HashMap)list_2.get(i);
%>          
            <li><a href="#" onclick="go_command_menu('<%=(String)map_2.get("command") %>')" class="<%=(submenu_idx.equals((String)map_2.get("sort")))?"subMenuOn":((submenu_idx.equals(""))?"subMenuOn":"") %>"><%=(String)map_2.get("menu_name") %></a></li>
<%
}
%> 	

<!-- 			
          <p class="a_r">
          <select name="admin_menu" id="admin_menu" onchange="go_command_menu(this.value)">
          <option value=''>메뉴 선택</option>
<%
for (int i=0;list_l.size()>i ;i++){	
	map_1=(HashMap)list_l.get(i);
%>          
            <option value="<%=(String)map_1.get("command") %>" <%=(submenu_id.equals((String)map_1.get("command")))?"selected":""%>><%=(String)map_1.get("menu_name") %></option>
<%
}
%>                        
          </select>
          </p>
 -->          
        </ul>
	
      </div>
